package com.sun.mybatisplus.generator;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.generator.AutoGenerator;
import com.baomidou.mybatisplus.generator.config.DataSourceConfig;
import com.baomidou.mybatisplus.generator.config.GlobalConfig;
import com.baomidou.mybatisplus.generator.config.StrategyConfig;
import com.baomidou.mybatisplus.generator.config.rules.NamingStrategy;

/**
 * @Author: Suncl
 * @Date: 2023/9/6 9:44
 */
public class MyGenerator {
    public static void main(String[] args) {
        DataSourceConfig dataSourceConfig = new DataSourceConfig();
//        dataSourceConfig.setDriverName("com.mysql.cj.jdbc.Driver");
        dataSourceConfig.setDriverName("oracle.jdbc.driver.OracleDriver");
        dataSourceConfig.setUrl("jdbc:mysql://127.0.0.1:3306/test?useUnicode=true&characterEncoding=utf8&useSSL=false&serverTimezone=CTT&&allowPublicKeyRetrieval=true");
        dataSourceConfig.setUrl("jdbc:oracle:thin:@172.16.101.77:1521/orcl1");
        dataSourceConfig.setUsername("h3_gic_dev");
        dataSourceConfig.setPassword("1");

        AutoGenerator generator = new AutoGenerator();
        generator.setDataSource(dataSourceConfig);

        GlobalConfig globalConfig = new GlobalConfig();
        globalConfig.setOutputDir("D:\\codebase\\javaLearn\\MybatisPlus\\src\\main\\java\\com\\sun");
        globalConfig.setOpen(false);
        globalConfig.setIdType(IdType.ASSIGN_UUID);
        globalConfig.setSwagger2(Boolean.TRUE);
        generator.setGlobalConfig(globalConfig);


        StrategyConfig strategyConfig = new StrategyConfig();
        strategyConfig.setInclude("INCOME_QUOTA_TRANSFORM");


        strategyConfig.setRestControllerStyle(false);
        strategyConfig.setControllerMappingHyphenStyle(true);
        strategyConfig.setEntityLombokModel(true);
        strategyConfig.setNaming(NamingStrategy.underline_to_camel);


        generator.setStrategy(strategyConfig);

        generator.execute();
    }
}
